package com.wry.spring.extension;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * <h1> 初始化Bean前后-扩展点 </h1>
 *
 * @author wry
 * @since 2025.04.06
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("orderServiceImpl")){
            System.out.println("postProcessBeforeInitialization orderServiceImpl bean初始化前扩展点 -> " + bean);
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("orderServiceImpl")){
            System.out.println("postProcessAfterInitialization orderServiceImpl bean初始后扩展点 -> " + bean);
        }
        return bean;
    }
}
